/**
 * @param {number[][]} classes
 * @param {number} extraStudents
 * @return {number}
 */
 var maxAverageRatio = function(classes, extraStudents) {
  let res = -1
  for(let i=0;i<classes.length;i++){
  let addExtra =  (classes[i][0]+extraStudents)/(classes[i][1]+extraStudents)
  let withoutExtra = 0
  for(let j=0;j<classes.length;j++){
    if(j!=i){
      withoutExtra += classes[j][0] / classes[j][1]
    }
  }
  res = Math.max(res,(addExtra+withoutExtra)/classes.length)
  }
  return res
};

maxAverageRatio( [[1,2],[3,5],[2,2]],2)